home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / andere sprachen / oberonv4 / oberon-src / system / host.mod (.txt) < prev    next >
Encoding:
Oberon Text  |  1996-04-09  |  4.3 KB  |  85 lines

  1. Syntax10.Scn.Fnt
  2. Syntax10i.Scn.Fnt
  3. StampElems
  4. Alloc
  5. 9 Apr 96
  6. Syntax10m.Scn.Fnt
  7. Syntax12i.Scn.Fnt
  8. LineElems
  9. Alloc
  10. MODULE Host;    (** SHML 19 Mar 96, 
  11.         This module encapsulates all system dependent variables and procedures of an Oberon System V4.
  12.         This is the version for Oberon for Amiga.
  13.         Created by Stefan H._M. Ludwig, Institute for Computer Systems, ETH Zurich, ludwig@inf.ethz.ch, 19 Mar 96
  14.     IMPORT Input, Display, Modules;
  15.         Host-: ARRAY 32 OF CHAR;    (** string identifying the host machine *)
  16.         TimeUnit-: LONGINT;    (** resolution of Input.Time(), TimeUnit ticks happen per second *)
  17.         OptionChar-: CHAR;    (** character used by command interpreters for specifying options *)
  18.         PathChar-: CHAR;    (** character used in file names for separating subdirectories *)
  19.         backed: BOOLEAN;
  20.     (* Support *) 
  21.     PROCEDURE Append(VAR to(*inout*): ARRAY OF CHAR; this: ARRAY OF CHAR);
  22.         (* append this to to, trim this to space left in to *)
  23.         VAR toLen, i, j: LONGINT;
  24.     BEGIN
  25.         i := -1;
  26.         REPEAT INC(i) UNTIL to[i] = 0X;
  27.         toLen := LEN(to)-1; j := 0;
  28.         WHILE (i # toLen) & (this[j] # 0X) DO to[i] := this[j]; INC(i); INC(j) END;
  29.         to[i] := 0X
  30.     END Append;
  31.     (* Exported procedures *) 
  32.     PROCEDURE Backup*(X, Y, W, H: INTEGER);
  33.         (** Backup screen area X, Y, W, H; (must be followed by Restore, 100) *)
  34.     BEGIN
  35.         ASSERT(~backed, 100);
  36.         backed := TRUE;
  37.         Display.CopyBlock(X, Y, W, H, X, -H, Display.replace)    (* backup into secondary bitmap *)
  38.     END Backup;
  39.     PROCEDURE Restore*(X, Y, W, H: INTEGER);
  40.         (** Restore screen area X, Y, W, H; (must be preceded by Backup, 100) *)
  41.     BEGIN
  42.         ASSERT(backed, 100);
  43.         backed := FALSE;
  44.         Display.CopyBlock(X, -H, W, H, X, Y, Display.replace)    (* restore from secondary bitmap *)
  45.     END Restore;
  46.     PROCEDURE IsFileNameChar*(ch: CHAR): BOOLEAN;    (** Is ch part of a valid file name? *)
  47.     BEGIN
  48.         CASE ch OF
  49.         | "A".."Z", "a".."z", "0".."9", ".", "/", "_", ":": RETURN TRUE
  50.         ELSE RETURN FALSE
  51.         END
  52.     END IsFileNameChar;
  53.     PROCEDURE CallError*(command: ARRAY OF CHAR; res: INTEGER; VAR msg(*out*): ARRAY OF CHAR);
  54.         (** Translate error message when the call of command fails; (res # 0, 100); (LEN(msg) >= 32, 101) *)
  55.         VAR i, j: INTEGER;
  56.     BEGIN
  57.         ASSERT(res # 0, 100); ASSERT(LEN(msg) >= 32, 101);
  58.         IF res > 0 THEN
  59.             COPY("Call error: ", msg); Append(msg, Modules.importing);
  60.             IF res = 1 THEN Append(msg, " not found")
  61.             ELSIF res = 2 THEN Append(msg, " not an obj-file")
  62.             ELSIF res = 3 THEN
  63.                 Append(msg, " imports ");
  64.                 Append(msg, Modules.imported); Append(msg, " with bad key")
  65.             ELSIF res = 4 THEN Append(msg, " corrupted obj file")
  66.             ELSIF res = 5 THEN Append(msg, command); Append(msg, " command not found")
  67.             ELSIF res = 6 THEN Append(msg, " has too many imports")
  68.             ELSIF res = 7 THEN Append(msg, " not enough space")
  69.             END
  70.         ELSIF res < 0 THEN
  71.             i := -1;
  72.             REPEAT INC(i) UNTIL (command[i] = ".") OR (command[i] = 0X);
  73.             IF command[i] = 0X THEN i := -1 END;
  74.             j := -1; 
  75.             REPEAT INC(i); INC(j); msg[j] := command[i] UNTIL command[i] = 0X;    (* copy procedure name *)
  76.             Append(msg, " not found")
  77.         END
  78.     END CallError;
  79. BEGIN
  80.     Host := "Amiga";
  81.     OptionChar := "\"; PathChar := "/";
  82.     TimeUnit := Input.TimeUnit;
  83.     backed := FALSE
  84. END Host.
  85.